package cn.larry.common.handlers;

import cn.larry.common.annotation.Wechath5CheckerAdaptor;
import cn.larry.common.exception.Wechath5handlersException;
import cn.larry.common.utils.ServletUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotNull;

/**
 * This is created,
 * but not necessarily updated by me.
 * Therefore, AUTHOR is useless.
 * 2022/12/28 13:18
 *
 * @Version 1.0
 * 【浏览器判断】
 */
@Slf4j
@Component
public class TestHandler extends Wechath5CheckerAdaptor {

    @Override
    public Object check(@NotNull Object object, String methodName) throws Wechath5handlersException {

        String browserType = null;
        try {
            String userAgent = ServletUtils.getRequest().getHeader("user-agent");
            log.info(getReqRealIp() + " " + userAgent);
        } catch (Exception e) {
            log.error("请求浏览器校验异常", e);
            throw new Wechath5handlersException("打开方式异常");
        }

        return object;
    }

}
